package com.ag.hmk.action;

import java.util.List;

import com.ag.bean.TbTeam;
import com.ag.common.BaseAction;
import com.ag.common.IDUtil;
import com.ag.hmk.service.impl.HmkUiltServImpl;

/**
 * 
 * @author hmk
 * 查询某一应急队伍信息
 */
public class FindOneTeamAction extends BaseAction {
	private static final long serialVersionUID = 3111488197703404952L;

	private HmkUiltServImpl hmkUiltServImpl;
	private String teamID;  //应急队伍ID
	private String findType1; //为1时导向到五库的详情，为2时导向到事件关联的详情出，为空时导向到队伍编辑处 。
	
	private TbTeam teamRst;
	
	/*
	 * 获得一条记录（by team id）
	 */
	public String getOneTeam()throws Exception{
		TbTeam team1 = null;
		try {
			String hql = "from TbTeam t left join fetch t.tbType where 1=1 ";
			if (teamID!=null && teamID.length()>0) {
				hql += " and t.a='"+IDUtil.PRESERVE+"' and t.teamId = " + teamID;
				List result=null;
				result = hmkUiltServImpl.query(hql, 0, 1);
				if (result!=null) {
					team1 = (TbTeam)result.iterator().next();
					System.out.println("==="+team1.getTeamId() +":"+team1.getTbType().getTpyeName());
					System.out.println("-----找到记录");
				}
			} else {
				System.out.println("---id 为空，没能找到记录");
			}
		} catch (Exception e) {
			e.printStackTrace();
			team1 = null;
		}
		
		this.setTeamRst(team1);
		
		if (findType1!=null && findType1.equals("1")) {
			//返回到队伍详情
			return "findOneTeamOK";
		}else if(findType1!=null && findType1.equals("2")){
			//返回到事件关联中的队伍详情
			return "gotoEventTeamDetail";
		}else{ 
			//返回到队伍编辑
			return "gotoEditTeam";
		}
		
	}


	public TbTeam getTeamRst() {
		return teamRst;
	}

	public void setTeamRst(TbTeam teamRst) {
		this.teamRst = teamRst;
	}

	public void setHmkUiltServImpl(HmkUiltServImpl hmkUiltServImpl) {
		this.hmkUiltServImpl = hmkUiltServImpl;
	}

	public void setTeamID(String teamID) {
		this.teamID = teamID;
	}
/*
	public void setTbTeamServImpl(TbTeamServImpl tbTeamServImpl) {
		this.tbTeamServImpl = tbTeamServImpl;
	}
	*/

	public void setFindType1(String findType1) {
		this.findType1 = findType1;
	}
}
